package openvpn

import (
	log "github.com/sirupsen/logrus"
	"vpn/app/global"
	"vpn/app/utils/shell"
	"vpn/template"
)

func RemoveConf() {
	shell.ShellCommandExec("rm -rf /opt/easy-rsa/*")
}

func Install(subnet string, mask string, clientConnEnable bool, password string) {
	SaveEnvConf(subnet, mask, clientConnEnable, password)
	log.Printf("环境变量配置已加载！")
	installScript := global.OpenvpnConf.InstallScriptPath
	saveOpenvpnConfScript := global.OpenvpnConf.SaveConfScriptPath
	createShellScriptTemplate(installScript, template.InstallShellScript, true)
	createShellScriptTemplate(saveOpenvpnConfScript, template.SaveConfShellScript, true)
	shell.ShellFileExec(installScript)
	log.Printf("安装脚本已执行！")
}
